#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
const int N = 60, M = N * N;
int h[N], e[M], ne[M], idx;
int st[N];
int ver, edge;
int n, m;
vector<int>ans1;
void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx++;
}

void dfs(int u, int fa)
{
	st[u] = 1;
	ans1.push_back(u);
	for (int i = h[u]; ~i; i = ne[i]) {
		int j = e[i];
		//cout << "j==" << j << endl;
		if (j == fa)continue;
		if (!st[j]) {
			dfs(j, u);
		}
	}
	return;
}
int main()
{
	cin >> n >> m;
	memset(h, -1, sizeof(h));
	while (m--) {
		int a, b;
		cin >> a >> b;
		//a++, b++;
		add(a, b);
		add(b, a);
	}
	/*for (int i = h[1]; ~i; i = ne[i]) {
		int j = e[i];
		cout << "i==1" << "   j==" << j << endl;
	}*/
	//cout << "h[1]==" << h[1] << endl;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (!st[i]) {
			ver = 0, edge = 0;
			ans1.clear();
			dfs(i, 0);
			ver = ans1.size();
			//cout << "ver===" << ver << endl;
			if (ver == 1) {
				ans++;
				continue;
			}
			bool flag = 0;
			for (auto x : ans1) {
				int cnt = 0;
				//cout << "x===" << x << endl;
				for (int j = h[x]; ~j; j = ne[j]) {
					int k = e[j];
					cnt++;
				}
				//cout << "cnt==" << cnt << endl;
				if (cnt != ver - 1) {
					flag = 1;
					break;
				}
			}
			//cout << "flag==" << flag << endl;
			if (!flag) {
				ans++;
			}
			//if (ver == 1 && edge == 1) {
			//	ans++;
			//	continue;
			//}
			//if (ver == 2 && edge == 2) {
			//	ans++;
			//	continue;
			//}
			//if (ver == 3 && edge == 3) {
			//	ans++;
			//	continue;
			//}
			////edge--;
			//cout << "ver==" << ver << "  edge==" << edge << endl;
			//if (ver * (ver - 1) / 2 == edge)ans++;
		}
	}
	cout << ans << endl;
	return 0;
}